var gulp = require('gulp');
var uglify = require('gulp-uglify'); // js压缩
var rename = require('gulp-rename');
var sourcemaps = require('gulp-sourcemaps');

//定义js合并压缩任务
gulp.task('build:js', function () {
    gulp.src('public/html/01.js')
        .pipe(uglify())
        .pipe(rename({ suffix: '.min' }))
        .pipe(gulp.dest('public/html/'));
})

gulp.task('build:js-map', function () {
    gulp.src('public/html/01.js')
        .pipe(sourcemaps.init())  //标记 map 记录始发点
        .pipe(uglify())
        .pipe(sourcemaps.write('../html2/', { addComment: false }))
        .pipe(gulp.dest('public/html2/'));
})


gulp.task('build', gulp.series('build:js', 'build:js-map'));